package cn.web.servlet;

import cn.domain.User;
import cn.service.Userservice;
import cn.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/userListServlet")
public class UserListServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Userservice userservice=new UserServiceImpl();
        List<User> users = userservice.findAll();
        request.setAttribute("users",users);
        System.out.println(users);//转发
        request.getRequestDispatcher("/list.jsp").forward(request,  response);

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
